import React from "react"
import {Button} from 'antd'
import {defaultAvatar} from "./init"


export const env = process.env.NODE_ENV
export const DEV = "development"
export const PROD = "production"

//API接口地址
//  export const HOST = env === DEV ? "http://120.76.200.3:9527" : "http://120.76.200.3:9527"
// export const HOST = env === DEV ? "http://localhost" : "http://admin.ld006.com:9527"
export const HOST = env === DEV ? "http://localhost" : (window.HOST || "http://192.168.7.25:8080")

export const PUBLIC_KEY = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCIP7zZVlCHvAH1wZBySmg2boPbAZz/OSft2p6fNJmgN1m9Br6GInuhTEiKPzYnp8JQhAYU6KgUUl4618S4JuEi9xQtMv20vsSO2f+JTYUq2dtJCWE2cToJHxgyl/ZwL5TEnRfG4whsIG53OaOQ/tyd7qEadGJDkRebQxKVOEcEIQIDAQAB";

export const regex_mobile = /^(13[0-9]|14[579]|15[0-3,5-9]|16[6]|17[0135678]|18[0-9]|19[89])\d{8}$/;

export const regex_userName = /^[a-zA-Z|\d|#|@|_|\-|.]{2,20}$/;
export const regex_password = /^[\x00-\xff]{6,20}$/;

export const regex_password6 = /^(?=.*[0-9].*)(?=.*[A-Za-z].*).{6,20}$/;

export const regex_name = /^[a-zA-Z\u4e00-\u9fa5\\d]{1,20}$/;

// 强：字母+数字+特殊字符 
//  const Strong = /^(?![a-zA-z]+$)(?!\d+$)(?![!@#$%^&*]+$)(?![a-zA-z\d]+$)(?![a-zA-z!@#$%^&*]+$)(?![\d!@#$%^&*]+$)[a-zA-Z\d!@#$%^&*]+$/;
export const Strong = /^.*(?=.{8,16})(?=.*\d)(?=.*[a-zA-Z])(?=.*[!@#$%^&*?\(\)+=\[\]\{\}_<>,.;:'"-]).*$/;
// 中：字母+数字，字母+特殊字符，数字+特殊字符
export const Middle = /^(?![a-zA-z]+$)(?!\d+$)(?![!@#$%^&*]+$)[a-zA-Z\d!@#$%^&*]+$/;
// 弱：纯数字，纯字母，纯特殊字符
export const Weak = /^(?:\d+|[a-zA-Z]+|[!@#$%^&*]+)$/;

export const pageSetting = {
	showSizeChanger: true,
	showQuickJumper: <Button size={'small'}>跳转</Button>,
	showTotal: (total, range) => (
		<div>
			共 <span className={'line-stress'}>{total}</span> 条,
			当前显示第 <span className={'line-stress'}>{range[0]}</span>-<span className={'line-stress'}>{range[1]}</span> 条
		</div>
	)
}

export const avatarPath = (url) => {
	if (!url) return defaultAvatar
	if (url.startsWith('http://') || url.startsWith('https://')) {
		return url
	}
	return `${HOST}/avatar/${url}`
}

//排序类型
export const orderType = {
	ascend: 'ASC',
	descend: 'DESC'
}